home *** CD-ROM | disk | FTP | other *** search
/ Usenet 1993 July / InfoMagic USENET CD-ROM July 1993.ISO / sources / unix / volume18 / elm2.2 / part22 < prev    next >
Encoding:
Internet Message Format  |  1989-04-12  |  49.1 KB

  1. Subject:  v18i101:  Elm mail system, release 2.2, Part22/22
  2. Newsgroups: comp.sources.unix
  3. Sender: sources
  4. Approved: rsalz@uunet.UU.NET
  5.  
  6. Submitted-by: dsinc!syd@uunet.UU.NET (Syd Weinstein)
  7. Posting-number: Volume 18, Issue 101
  8. Archive-name: elm2.2/part22
  9.  
  10. #!/bin/sh
  11. # this is part 22 of a multipart archive
  12. # do not concatenate these parts, unpack them in order with /bin/sh
  13. # file src/utils.c continued
  14. #
  15. CurArch=22
  16. if test ! -r s2_seq_.tmp
  17. then echo "Please unpack part 1 first!"
  18.      exit 1; fi
  19. ( read Scheck
  20.   if test "$Scheck" != $CurArch
  21.   then echo "Please unpack part $Scheck next!"
  22.        exit 1;
  23.   else exit 0; fi
  24. ) < s2_seq_.tmp || exit 1
  25. echo "x - Continuing file src/utils.c"
  26. sed 's/^X//' << 'SHAR_EOF' >> src/utils.c
  27. X      dprint(1, (debugfile, "\nDump of stats for mailfile %s;\n",
  28. X           (folder_type == NON_SPOOL ? cur_folder : cur_tempfolder)));
  29. X
  30. X      dprint(1,  (debugfile, "\tinode: %d, mode: %o, uid: %d, ",
  31. X            buffer.st_ino, buffer.st_mode, buffer.st_uid));
  32. X
  33. X      dprint(1, (debugfile, 
  34. X         "gid: %d, size: %d\n\n", buffer.st_gid, buffer.st_size));
  35. X
  36. X      dprint(1, (debugfile, "\toffset into file = %l\n", ftell(mailfile)));
  37. X    }
  38. X    else
  39. X      dprint(1, (debugfile, 
  40. X         "\nfstat on mailfile '%s' failed with error %s!!\n\n",
  41. X               (folder_type == NON_SPOOL ? cur_folder : cur_tempfolder),
  42. X            error_name(errno)));
  43. X}
  44. X    
  45. Xemergency_exit()
  46. X{
  47. X    /** used in dramatic cases when we must leave without altering
  48. X        ANYTHING about the system... **/
  49. X    char buffer[SLEN];
  50. X    char *mk_lockname();
  51. X
  52. X    dprint(1, (debugfile, 
  53. X     "\nERROR: Something dreadful is happening!  Taking emergency exit!!\n\n"));
  54. X    dprint(1, (debugfile,
  55. X         "  possibly leaving behind the following files;\n"));
  56. X    dprint(1, (debugfile,
  57. X         "     The mailbox tempfile : %s\n", cur_tempfolder));
  58. X    if(folder_type == SPOOL) dprint(1, (debugfile,
  59. X         "     The mailbox lock file: %s\n", mk_lockname(cur_folder)));
  60. X    dprint(1, (debugfile,
  61. X         "     The composition file : %s%d\n", temp_file, getpid()));
  62. X    dprint(1, (debugfile,
  63. X         "     The readmsg data file: %s/%s\n", home, readmsg_file));
  64. X
  65. X    Raw(OFF);
  66. X    if (cursor_control)  transmit_functions(OFF);
  67. X    if (hp_terminal)     softkeys_off();
  68. X
  69. X    if (cursor_control)
  70. X      MoveCursor(LINES, 0);
  71. X
  72. X    PutLine0(LINES,0, 
  73. X        "\nEmergency exit taken! All temp files intact!\n\n");
  74. X
  75. X    exit(1);
  76. X}
  77. X
  78. X/*ARGSUSED*/
  79. X/*VARARGS0*/
  80. X
  81. Xleave(val)
  82. Xint val;    /* not used, placeholder for signal catching! */
  83. X{
  84. X    char buffer[SLEN];
  85. X
  86. X    dprint(2, (debugfile, "\nLeaving mailer normally (leave)\n"));
  87. X
  88. X    Raw(OFF);
  89. X    if (cursor_control)  transmit_functions(OFF);
  90. X    if (hp_terminal)     softkeys_off();
  91. X
  92. X    sprintf(buffer,"%s%d",temp_file, getpid());  /* editor buffer */
  93. X    (void) unlink(buffer);
  94. X
  95. X    if (folder_type == SPOOL) {
  96. X      (void) unlink(cur_tempfolder);
  97. X    }
  98. X
  99. X    sprintf(buffer,"%s/%s", home, readmsg_file);  /* readmsg temp */
  100. X    (void) unlink(buffer);
  101. X
  102. X    unlock();                /* remove lock file if any */
  103. X
  104. X    if(!batch_only) {
  105. X      MoveCursor(LINES,0);
  106. X      NewLine();
  107. X    }
  108. X
  109. X    exit(0);
  110. X}
  111. X
  112. Xsilently_exit()
  113. X{
  114. X    /** This is the same as 'leave', but it doesn't remove any non-pid
  115. X        files.  It's used when we notice that we're trying to create a
  116. X        temp mail file and one already exists!!
  117. X    **/
  118. X    char buffer[SLEN];
  119. X
  120. X    dprint(2, (debugfile, "\nLeaving mailer quietly (silently_exit)\n"));
  121. X
  122. X    Raw(OFF);
  123. X    if (cursor_control)  transmit_functions(OFF);
  124. X    if (hp_terminal)     softkeys_off();
  125. X
  126. X    sprintf(buffer,"%s%d",temp_file, getpid());  /* editor buffer */
  127. X    (void) unlink(buffer);
  128. X
  129. X    MoveCursor(LINES,0);
  130. X    NewLine();
  131. X
  132. X    exit(0);
  133. X}
  134. X
  135. X/*ARGSUSED0*/
  136. X
  137. Xleave_locked(val)
  138. Xint val;    /* not used, placeholder for signal catching! */
  139. X{
  140. X    /** same as leave routine, but don't disturb lock file **/
  141. X
  142. X    char buffer[SLEN];
  143. X
  144. X        dprint(3, (debugfile,
  145. X        "\nLeaving mailer due to presence of lock file (leave_locked)\n"));
  146. X
  147. X    Raw(OFF);
  148. X    if (cursor_control)  transmit_functions(OFF);
  149. X    if (hp_terminal)     softkeys_off();
  150. X
  151. X    sprintf(buffer,"%s%d",temp_file, getpid());  /* editor buffer */
  152. X    (void) unlink(buffer);
  153. X
  154. X    (void) unlink(cur_tempfolder);            /* temp mailbox */
  155. X
  156. X    MoveCursor(LINES,0);
  157. X    NewLine();
  158. X    exit(0);
  159. X}
  160. X
  161. Xint
  162. Xget_page(msg_pointer)
  163. Xint msg_pointer;
  164. X{
  165. X    /** Ensure that 'current' is on the displayed page,
  166. X        returning non-zero iff the page changed! **/
  167. X
  168. X    register int first_on_page, last_on_page;
  169. X
  170. X    first_on_page = (header_page * headers_per_page) + 1;
  171. X
  172. X    last_on_page = first_on_page + headers_per_page - 1;
  173. X
  174. X    if (selected)    /* but what is it on the SCREEN??? */
  175. X      msg_pointer = compute_visible(msg_pointer);
  176. X
  177. X    if (selected && msg_pointer > selected) 
  178. X      return(FALSE);    /* too far - page can't change! */
  179. X
  180. X    if (msg_pointer > last_on_page) {
  181. X      header_page = (int) (msg_pointer-1)/ headers_per_page;
  182. X      return(1);
  183. X    }
  184. X    else if (msg_pointer < first_on_page) {
  185. X      header_page = (int) (msg_pointer-1) / headers_per_page;
  186. X      return(1);
  187. X    }
  188. X    else
  189. X      return(0);
  190. X}
  191. X
  192. Xchar *nameof(filename)
  193. Xchar *filename;
  194. X{
  195. X    /** checks to see if 'filename' has any common prefixes, if
  196. X        so it returns a string that is the same filename, but 
  197. X        with '=' as the folder directory, or '~' as the home
  198. X        directory..
  199. X    **/
  200. X
  201. X    static char buffer[STRING];
  202. X    register int i = 0, iindex = 0;
  203. X
  204. X    if (strncmp(filename, folders, strlen(folders)) == 0) {
  205. X      if (strlen(folders) > 0) {
  206. X        buffer[i++] = '=';
  207. X        iindex = strlen(folders);
  208. X        if(filename[iindex] == '/')
  209. X          iindex++;
  210. X      }
  211. X    }
  212. X    else if (strncmp(filename, home, strlen(home)) == 0) {
  213. X      if (strlen(home) > 0) {
  214. X        buffer[i++] = '~';
  215. X        iindex = strlen(home);
  216. X      }
  217. X    }
  218. X    else iindex = 0;
  219. X
  220. X    while (filename[iindex] != '\0')
  221. X      buffer[i++] = filename[iindex++];
  222. X    buffer[i] = '\0';
  223. X    
  224. X    return( (char *) buffer);
  225. X}
  226. SHAR_EOF
  227. echo "File src/utils.c is complete"
  228. chmod 0444 src/utils.c || echo "restore of src/utils.c fails"
  229. echo "x - extracting src/validname.c (Text)"
  230. sed 's/^X//' << 'SHAR_EOF' > src/validname.c &&
  231. X
  232. Xstatic char rcsid[] = "@(#)$Id: validname.c,v 2.8 89/03/25 21:47:34 syd Exp $";
  233. X
  234. X/*******************************************************************************
  235. X *  The Elm Mail System  -  $Revision: 2.8 $   $State: Exp $
  236. X *
  237. X *             Copyright (c) 1986, 1987 Dave Taylor
  238. X *             Copyright (c) 1988, 1989 USENET Community Trust
  239. X *******************************************************************************
  240. X * Bug reports, patches, comments, suggestions should be sent to:
  241. X *
  242. X *    Syd Weinstein, Elm Coordinator
  243. X *    elm@dsinc.UUCP            dsinc!elm
  244. X *
  245. X *******************************************************************************
  246. X * $Log:    validname.c,v $
  247. X * Revision 2.8  89/03/25  21:47:34  syd
  248. X * Initial 2.2 Release checkin
  249. X * 
  250. X *
  251. X ******************************************************************************/
  252. X
  253. X#include "defs.h"
  254. X
  255. X#include <stdio.h>
  256. X
  257. X#ifdef PWDINSYS
  258. X#  include <sys/pwd.h>
  259. X#else
  260. X#  include <pwd.h>
  261. X#endif
  262. X
  263. Xint
  264. Xvalid_name(name)
  265. Xchar *name;
  266. X{
  267. X    /** Determine whether "name" is a valid logname on this system.
  268. X        It is valid if there is a password entry, or if there is
  269. X        a mail file in the mail spool directory for "name".
  270. X     **/
  271. X
  272. X#ifdef NOCHECK_VALIDNAME         /* Force a return of valid */
  273. X
  274. X    return(TRUE);
  275. X
  276. X#else
  277. X
  278. X    char filebuf[SLEN];
  279. X    struct passwd *getpwnam();
  280. X
  281. X    if(getpwnam(name) != NULL)
  282. X      return(TRUE);
  283. X
  284. X    sprintf(filebuf,"%s/%s", mailhome, name);
  285. X    if (access(filebuf, ACCESS_EXISTS) == 0)
  286. X      return(TRUE);
  287. X
  288. X    return(FALSE);
  289. X
  290. X#endif
  291. X}
  292. SHAR_EOF
  293. chmod 0444 src/validname.c || echo "restore of src/validname.c fails"
  294. echo "x - extracting test/test.empty (Text)"
  295. sed 's/^X//' << 'SHAR_EOF' > test/test.empty &&
  296. SHAR_EOF
  297. chmod 0644 test/test.empty || echo "restore of test/test.empty fails"
  298. echo "x - extracting test/test.mail (Text)"
  299. sed 's/^X//' << 'SHAR_EOF' > test/test.mail &&
  300. XFrom root Wed Oct 30 14:03:36 1985
  301. X>From srmmail Wed Oct 30 14:10:08 1985  remote from veeger
  302. X>From hplabs Wed Oct 30 14:00:16 1985 remote from hpcnof
  303. X>From hpl-opus!poulton  Wed Oct 30 02:06:16 1985 remote from hplabs
  304. XDate: Wed, 30 Oct 85 01:55:05 pst
  305. XFrom: <hplabs!hpl-opus!poulton>
  306. XReceived: by HP-VENUS id AA26352; Wed, 30 Oct 85 01:55:05 pst
  307. XMessage-Id: <8510300955.AA26352@HP-VENUS>
  308. XTo: hplabs!hpldat!taylor
  309. XSubject: Re: announce(1)
  310. X
  311. XThe announce I got was shar'd July 8.   NLEN was not defined in that
  312. Xsource, just used.  LONG_SLEN is not defined in the newmail(1)
  313. Xthat you sent me.  What system are you running on?
  314. XMy s500 doesn't have these def's.
  315. X
  316. X    -> Monday, January 3rd: Call your mother
  317. X
  318. XAs to announce --> newmail: why the switch?
  319. XSeems like both are useful, in different situations.
  320. X
  321. XKen Poulton
  322. XHPL
  323. X
  324. X
  325. X
  326. X
  327. XFrom root Wed Oct 30 14:03:39 1985
  328. X>From srmmail Wed Oct 30 14:10:12 1985  remote from veeger
  329. X>From hplabs Wed Oct 30 13:59:53 1985 remote from hpcnof
  330. X>From fowler  Wed Oct 30 12:57:11 1985 remote from hplabs
  331. XDate: Wed, 30 Oct 85 12:57:11 pst
  332. XFrom: Greg Fowler <hplabs!fowler>
  333. XReceived: by HP-VENUS id AA12562; Wed, 30 Oct 85 12:57:11 pst
  334. XMessage-Id: <8510302057.AA12562@HP-VENUS>
  335. XTo: mail-men@rochester
  336. XSubject: Re: Summary of Network Mail Headers
  337. XReferences: <36700044@hpcnof.UUCP>
  338. XPriority: Most Urgent
  339. X
  340. XI believe your introduction referred to the uucp network.  usenet is the network news
  341. Xsoftware mechanism and isn't a "network".
  342. X
  343. X    - > February 19, 1986
  344. X    -
  345. X    -    A longer test of the system
  346. X    -
  347. X
  348. X    Greg
  349. X
  350. X
  351. X
  352. XFrom root Wed Oct 30 14:13:23 1985
  353. X>From srmmail Wed Oct 30 14:20:08 1985  remote from veeger
  354. X>From root Wed Oct 30 14:01:57 1985 remote from hpcnof
  355. XTo: DCC@hplabs
  356. XSubject: Log of backup tape #1
  357. X
  358. XFull Backup starting at Wed Oct 30 12:45:14 MST 1985
  359. X
  360. X
  361. Xbacking up directories: 
  362. X    ./users/fh ./users/rmd ./users/vince ./users/roberts ./users/row ./users/dt ./lost+found ./users/lost+found ./users/scb ./users/kevin ./users/du
  363. X
  364. X
  365. X
  366. X
  367. X
  368. XFrom root Wed Oct 30 15:33:24 1985
  369. X>From srmmail Wed Oct 30 15:40:26 1985  remote from veeger
  370. X>From root Wed Oct 30 15:37:17 1985 remote from hpcnof
  371. XTo: root, uucp, taylor@hplabs.ARPA
  372. XSubject: Log of backup tape #2
  373. X
  374. Xbacking up directories: 
  375. X    ./users/fh ./users/rmd ./users/vince ./users/roberts ./users/row ./users/dt ./lost+found ./users/lost+found ./users/scb ./users/kevin ./users/du
  376. X
  377. X
  378. X
  379. X
  380. Xbacking up directories: 
  381. X    ./users/sbh ./users/ges ./users/cpb ./users/amy ./net ./users/root ./users/balza ./dev ./users/remple ./users/jr ./users/mwr ./users/larryf
  382. X
  383. X
  384. X
  385. X
  386. X
  387. XFrom root Sun Dec  8 22:50:18 1985
  388. X>From srmmail Mon Dec  9 00:50:05 1985 remote from veeger
  389. X>From root Mon Dec  9 00:41:15 1985 remote from hpcnof
  390. X>From JLarson.pa@Xerox.ARPA  Sun Dec  8 20:45:55 1985 remote from hplabs
  391. XDate: 8 Dec 85 20:36:36 PST (Sunday)
  392. XFrom: hplabs!JLarson.pa@Xerox.ARPA
  393. XSubject: How's it going, anyway?
  394. XTo: hpcnou!dat@HPLABS.ARPA (Dave Taylor)
  395. XCc: JLarson.pa@Xerox.ARPA
  396. X
  397. XHow are things with you?  Could you send me that paper we were talking
  398. Xabout?  
  399. X
  400. X    Thanks
  401. X
  402. XJohn Larson
  403. XXerox Palo Alto Research Center
  404. X3333 Coyote Hill Road
  405. XPalo Alto, Ca  94304
  406. X
  407. X
  408. X
  409. X
  410. XFrom To:host!root@hplabs.HP.COM Wed Aug  7 19:58:30 1985
  411. X#From uucp Wed Aug  7 19:55:12 1985  remote from veeger
  412. X#From hplabs Wed Aug  7 19:48:10 1985 remote from hpcnof
  413. X#From RICHER@SUMEX-AIM  Wed Aug  7 09:23:12 1985 remote from hplabs
  414. XReceived: by HP-VENUS id AA18269; Wed, 7 Aug 85 09:11:48 pdt
  415. XDate: Tue 6 Aug 85 09:12:37-PDT
  416. X#From: Mark Richer <hplabs!RICHER@SUMEX-AIM>
  417. XReceived: by HP-VENUS via CSNET; 7 Aug 1985 09:11:37-PDT (Wed)
  418. XReceived: from sumex-aim.arpa by csnet-relay.arpa id a015812; 6 Aug 85 12:14 EDT
  419. XTo: hpcnof!veeger!hpcnou!dat%hplabs.csnet@CSNET-RELAY
  420. XVia:  CSNet; 7 Aug 85 9:11-PDT
  421. XSubject: Re: AI in Education mailing list...
  422. XCc: RICHER@SUMEX-AIM
  423. XIn-Reply-To: <8508030243.AA27641@HP-VENUS>
  424. XMessage-Id: <12132987812.61.RICHER@SUMEX-AIM.ARPA>
  425. X
  426. XI added you to aied.  This message may be of interest to you:
  427. X
  428. XArtificial Intelligence in Education Meeting at IJCAI 85
  429. X---------- ------------ -- --------- ------- -- ----- --
  430. X
  431. XPlace: Math Sciences Auditorium (a.k.a. Math 4000A), UCLA campus
  432. XTime: 6:30 pm, Tuesday, Aug. 20, 1985  (length: 1 - 1 1/4 hr)
  433. X
  434. XAgenda:
  435. X    I have two speakers scheduled to make presentations that
  436. Xshould stimulate questions and discussions:
  437. X
  438. X    (1) Short Announcements
  439. X
  440. X    (2) Jeff Bonar, Research Scientist, Learning Research and
  441. X    Development Center (LRDC), University of Pittsburgh
  442. X
  443. X    --- on-going ICAI research projects at LRDC
  444. X    --- dissemination of ICAI technology in the form of software
  445. X    tools, workshops, written materials, and video tapes.
  446. X
  447. X    (3) Gary Fine, Product Engineering Manager, INTELLICORP,
  448. X    formerly with a company producing CAI products, also graduate
  449. X    work in ICAI  
  450. X
  451. X    --- bridging the gap between current ICAI technology and the
  452. X    real world
  453. X
  454. X[IJCAI-85, the 9th International Joint Conference on Artificial
  455. XIntelligence is being held at UCLA Campus, August 18-23, 1985.  This
  456. Xconference is co-sponsered by the American Association for Artificial
  457. XIntelligence (AAAI) this year, and I have been told by their office
  458. Xthat only walk-in registration is available at this time.  For more
  459. Xinformation, contact AAAI:  AAAI-OFFICE@SUMEX-AIM.ARPA
  460. X                AAAI, 445 Burgess Drive, Menlo Park, CA 94025
  461. X                or call (415) 328-3123]
  462. X
  463. XDirect questions on the AI in ED meeting (only) to Mark Richer,
  464. XRICHER@SUMEX-AIM.ARPA
  465. X-------
  466. X
  467. X
  468. X
  469. X
  470. XFrom root Tue Sep 24 09:53:24 1985
  471. X>From HPMAIL-gateway Tue Sep 24  9:46:47 1985  remote from veeger
  472. X>From Simon_CINTZ_/_HPD600/TR  Tue Sep 24  9:46:47 1985  remote from hpmail
  473. XDate:   Tue, 24 Sep 85  9:14:00 MDT
  474. XFrom:   Simon_CINTZ_/_HPD600/TR  (Simon Cintz)
  475. XSubject: ITF
  476. XFrom:   Simon_CINTZ_/_HPD600/TR  (Simon Cintz)
  477. XTo:     Dave_TAYLOR_/_HPF100/00
  478. X
  479. XDave -
  480. X
  481. XJust as one programming language doesn't suit the needs of
  482. Xall programmers, one authoring facility will probably not
  483. Xsuit the needs of all HP entities that require CBT -- at least
  484. Xnot in the near future.  Of course, this is my personal opinion
  485. Xand if I'm wrong, it won't be the first time.
  486. X
  487. XGood luck.
  488. X
  489. X
  490. X                                           - Simon
  491. X
  492. XFrom root Mon Oct 21 10:43:37 1985
  493. X>From srmmail Mon Oct 21 10:30:16 1985  remote from veeger
  494. X>From root Mon Oct 21 10:28:58 1985 remote from hpcnof
  495. X>From DLS.MDC%office-X.arpa@CSNET-RELAY  Mon Oct 21 01:57:05 1985 remote from hplabs
  496. XReceived: by HP-VENUS id AA17376; Mon, 21 Oct 85 01:57:05 pdt
  497. XDate: 21 Oct 85 01:02 EDT
  498. XFrom: Duane Stone / McDonnell Douglas / CSC-ASD <hplabs!DLS.MDC%office-1.arpa@CSNET-RELAY>
  499. XReceived: by HP-VENUS via CSNET; 21 Oct 1985 01:57:01-PDT (Mon)
  500. XReceived: from office-1.arpa by CSNET-RELAY.ARPA id a019220; 21 Oct 85 1:18 EDT
  501. XTo: Dave Taylor <hpcnou!dat%hplabs.csnet@CSNET-RELAY>
  502. XVia:  CSNet; 21 Oct 85 1:56-PDT
  503. XSubject: Re: More Mail Headers...
  504. XMessage-Id: <MDC-DLS-7W9CS@OFFICE-1>
  505. XComment: Dave -- this is the body of the message I previously 'sent' to you via
  506. X
  507. Xa Journal.
  508. X
  509. XI might suggest re-wording the para on Author -- my associates might object to 
  510. X'strange' -- something like:
  511. X
  512. X   This is used to credit the original author, or to give credit on article 
  513. X   excerpts (from Newspapers, magazines, books, etc).
  514. X
  515. XOne field which I forgot is:
  516. X
  517. X   Length:  This is computed when the message is sent and gives the recipients 
  518. X   an estimate of the number of pages in the document.
  519. X
  520. X   Example:
  521. X
  522. X      Length: 6 pages [estimate]
  523. X
  524. XAccess:
  525. X
  526. X   Used to declare whether a Journal item should be Public or Private (to those
  527. X   that are on the distribution list or Extended Access list)
  528. X
  529. X   Example:
  530. X
  531. X      Access: Unrestricted
  532. X
  533. XAcknowledge-Delivery:
  534. X
  535. X   Used to request the system mailer send back a message when it has 
  536. X   successfully delivered the item.
  537. X
  538. X   Example:
  539. X
  540. X      Acknowledge-Delivery: Requested
  541. X
  542. XAcknowledge-Receipt:
  543. X
  544. X   Used to to ask the recipient to acknowledge receipt of the message.
  545. X
  546. X   Example:
  547. X
  548. X   Acknowledge-Receipt: Requested
  549. X
  550. XAddendum-To:
  551. X
  552. X   A pointer to a previously submitted Journal item.
  553. X
  554. X   Example:
  555. X
  556. X      Addendum-To: <ASD,1234,>
  557. X
  558. XDelivery-Timing:
  559. X
  560. X   Used by the sender to indicate when the message should be submitted to the 
  561. X   mailer.
  562. X
  563. X      Examples:
  564. X
  565. X         Rush:       -   immediate
  566. X
  567. X         Soon:       -   as soon as possible
  568. X
  569. X         Defer:      -   overnight
  570. X
  571. X         Start-Delivery: DATE TIME
  572. X
  573. X         Stop-Delivery:  DATE TIME (if not yet delivered)
  574. X
  575. XDisposition-Code:
  576. X
  577. X   Used by the system to group Journal items into one of several classes for 
  578. X   eventual archive to tape and as an indicator of how long the archive tapes 
  579. X   should be retained.
  580. X
  581. X   Example:
  582. X
  583. X      Disposition-Code: Temporary (2 years)
  584. X
  585. XExtended-access:
  586. X
  587. X   Used with private Journal items to allow access by other than those on the 
  588. X   distribution list.
  589. X
  590. X   Example:
  591. X
  592. X      Extended-access: ASD.MDC
  593. X
  594. XLocation:
  595. X
  596. X   Used to submit the message to the Journal.  The adressees receive a short 
  597. X   citation with other header fields and a "Location:" field pointing to a file
  598. X   in an electronic library.
  599. X
  600. X   Example:
  601. X
  602. X      Location: <MDC,1234,>
  603. X
  604. XPart-Of:
  605. X
  606. X   A pointer to a previously submitted Journal item.
  607. X
  608. X   Example:
  609. X
  610. X      Part-Of: <MDC,1234,>
  611. X
  612. XRoute-To:
  613. X
  614. X   Used to send a message "in-turn" to addressees in the "To:" field -- as 
  615. X   opposed to the broadcast method of delivery where everyone gets the message 
  616. X   "simultaneously".  Any addresses in the "Cc:" field receive a copy of the 
  617. X   message each time it is passed from one adressee to the next in the "To:" 
  618. X   field.
  619. X
  620. X   Example:
  621. X
  622. X      Routed-to: {addresses in To field}
  623. X
  624. XSigned:
  625. X
  626. X   Created when the user employs the Sign command; used to electronically sign 
  627. X   a message.  It affixes a signature-block to a message.  A "Verify Signature"
  628. X   command is available to recipients that lets them find out if anyone has 
  629. X   changed the body of the message since the message was signed.
  630. X
  631. X   Example:
  632. X
  633. X          SIGNED
  634. X      
  635. X      Duane L. Stone
  636. X      App. Dev. Mgr.
  637. X
  638. XSupersedes:
  639. X
  640. X   A pointer to a previously submitted Journal item.
  641. X
  642. X   Example:
  643. X
  644. X      Supersedes: <MDC,1234,>
  645. X
  646. X
  647. X--- last line of the file --
  648. SHAR_EOF
  649. chmod 0644 test/test.mail || echo "restore of test/test.mail fails"
  650. echo "x - extracting utils/Makefile.SH (Text)"
  651. sed 's/^X//' << 'SHAR_EOF' > utils/Makefile.SH &&
  652. Xcase $CONFIG in
  653. X'')
  654. X    if test ! -f config.sh; then
  655. X    ln ../config.sh . || \
  656. X    ln ../../config.sh . || \
  657. X    ln ../../../config.sh . || \
  658. X    (echo "Can't find config.sh."; exit 1)
  659. X    fi
  660. X    . ./config.sh
  661. X    ;;
  662. Xesac
  663. Xcase "$0" in
  664. X*/*) cd `expr X$0 : 'X\(.*\)/'` ;;
  665. Xesac
  666. X
  667. Xecho "Extracting utils/Makefile (with variable substitutions)"
  668. Xcat >Makefile <<!GROK!THIS!
  669. X
  670. X# @(#)$Id: Makefile.SH,v 2.17 89/03/25 21:47:36 syd Exp $
  671. X#
  672. X#  Makefile for the Elm system utilities
  673. X#
  674. X#    Copyright (c) 1986, 1987 Dave Taylor
  675. X#    Copyright (c) 1988, 1989 USENET Community Trust
  676. X#
  677. X# Bug reports, patches, comments, suggestions should be sent to:
  678. X#
  679. X#    Syd Weinstein - elm@dsinc.UUCP
  680. X#            dsinc!elm
  681. X#
  682. X# $Log:    Makefile.SH,v $
  683. X# Revision 2.17  89/03/25  21:47:36  syd
  684. X# Initial 2.2 Release checkin
  685. X# 
  686. X#
  687. X# Variables
  688. X#    Variables established by Configure
  689. XCC        =    $cc
  690. XCCFLAGS        =    $ccflags $xencf
  691. XCHMOD        =    $chmod
  692. XCP        =    $cp
  693. XDEST        =    $bin
  694. XECHO        =    $echo
  695. XLFLAGS        =    $ldflags $xenlf
  696. XLIB        =    $lib
  697. XLIB2        =     $libs
  698. XLIBS        =    $termlib $dbm
  699. XLINT        =    $lint
  700. XLN        =    $ln
  701. XMAKE        =    $make
  702. XMV        =    $mv
  703. XOPTIMIZE    =    $optimize
  704. XRM        =     $rm -f
  705. XTOUCH        =    $touch
  706. X!GROK!THIS!
  707. X
  708. Xcat >>Makefile <<'!NO!SUBS!'
  709. X#    Variables you may want to manually edit
  710. X#        If you want debug logging then you'll
  711. X#        want to uncomment the following.
  712. X#DEBUG        =    -DDEBUG
  713. X
  714. X#    Other general variables
  715. XBIN        =    ../bin
  716. XCFLAGS        =    $(CCFLAGS) $(OPTIMIZE) -I$(INCLDIR) $(DEBUG) $(DACSNET) 
  717. XINCLDIR        =    ../hdrs
  718. XLINTFLAGS    =    -I$(INCLDIR)
  719. XSHELL        =    /bin/sh
  720. X
  721. X#    Lists
  722. X#        List of installed programs - excludes wnewmail, which is
  723. X#        handled separately
  724. XINSTALL_LIST    =    $(DEST)/answer        \
  725. X            $(DEST)/arepdaemon    \
  726. X            $(DEST)/autoreply    \
  727. X            $(DEST)/checkalias    \
  728. X            $(DEST)/fastmail    \
  729. X            $(DEST)/frm        \
  730. X            $(DEST)/listalias    \
  731. X            $(DEST)/messages    \
  732. X            $(DEST)/newalias    \
  733. X            $(DEST)/newmail        \
  734. X            $(DEST)/printmail    \
  735. X            $(DEST)/readmsg
  736. X
  737. X#        List of remotely install programs
  738. XREMOTE_LIST    =    $(REMOTE)$(DEST)/answer        \
  739. X            $(REMOTE)$(DEST)/arepdaemon    \
  740. X            $(REMOTE)$(DEST)/autoreply    \
  741. X            $(REMOTE)$(DEST)/checkalias    \
  742. X            $(REMOTE)$(DEST)/fastmail    \
  743. X            $(REMOTE)$(DEST)/frm        \
  744. X            $(REMOVE)$(DEST)/listalias    \
  745. X            $(REMOVE)$(DEST)/messages    \
  746. X            $(REMOVE)$(DEST)/newalias    \
  747. X            $(REMOVE)$(DEST)/newmail    \
  748. X            $(REMOVE)$(DEST)/printmail    \
  749. X            $(REMOVE)$(DEST)/readmsg
  750. X
  751. X#        List of programs in bin directory
  752. XBINARY_LIST    =    $(BIN)/answer        \
  753. X            $(BIN)/arepdaemon    \
  754. X            $(BIN)/autoreply    \
  755. X            $(BIN)/checkalias    \
  756. X            $(BIN)/fastmail        \
  757. X            $(BIN)/frm        \
  758. X            $(BIN)/listalias    \
  759. X            $(BIN)/messages        \
  760. X            $(BIN)/newalias        \
  761. X            $(BIN)/newmail        \
  762. X            $(BIN)/printmail    \
  763. X            $(BIN)/readmsg
  764. X
  765. X#        List of programs to $(LINT) - only C programs
  766. XLINT_LIST    =    answer_lint    \
  767. X            arepdaemon_lint    \
  768. X            autoreply_lint    \
  769. X            fastmail_lint    \
  770. X            frm_lint    \
  771. X            listalias_lint    \
  772. X            newalias_lint    \
  773. X            newmail_lint    \
  774. X            readmsg_lint
  775. X
  776. X#    List of all object files in all util programs (used in parallel makes)
  777. XUTIL_OBJ    =    answer.o        \
  778. X            arepdaem.o         \
  779. X            autoreply.o        \
  780. X            expand.o        \
  781. X            fastmail.o        \
  782. X            from.o            \
  783. X            listalias.o        \
  784. X            newalias.o        \
  785. X            newmail.o        \
  786. X            readmsg.o        \
  787. X            ../src/opt_utils.o    \
  788. X            ../src/string2.o    \
  789. X            ../src/validname.o
  790. X
  791. X#    Lists of source and object files for each C program
  792. XANSWER_SRC    =    answer.c ../src/opt_utils.c
  793. XANSWER_OBJ    =    answer.o ../src/opt_utils.o
  794. XAREPDAEMON_SRC    =    arepdaem.c ../src/opt_utils.c
  795. XAREPDAEMON_OBJ    =    arepdaem.o ../src/opt_utils.o
  796. XAUTOREPLY_SRC    =    autoreply.c ../src/opt_utils.c
  797. XAUTOREPLY_OBJ    =    autoreply.o ../src/opt_utils.o
  798. XFASTMAIL_SRC    =    fastmail.c ../src/opt_utils.c
  799. XFASTMAIL_OBJ    =    fastmail.o ../src/opt_utils.o
  800. XFRM_SRC        =    from.c expand.c ../src/opt_utils.c ../src/string2.c
  801. XFRM_OBJ        =    from.o expand.o ../src/opt_utils.o ../src/string2.o
  802. XLISTALIAS_SRC    =    listalias.c
  803. XLISTALIAS_OBJ    =    listalias.o
  804. XNEWALIAS_SRC    =    newalias.c ../src/validname.c ../src/opt_utils.c
  805. XNEWALIAS_OBJ    =    newalias.o ../src/validname.o ../src/opt_utils.o
  806. XNEWMAIL_SRC    =    newmail.c expand.c ../src/opt_utils.c ../src/string2.c
  807. XNEWMAIL_OBJ    =    newmail.o expand.o ../src/opt_utils.o ../src/string2.o
  808. XREADMSG_SRC    =    readmsg.c ../src/opt_utils.c ../src/string2.c
  809. XREADMSG_OBJ    =    readmsg.o ../src/opt_utils.o ../src/string2.o
  810. X
  811. X# Standard targets
  812. Xall:            objects $(BINARY_LIST)
  813. X
  814. X#    This unusual target enables highly efficial compilation of object files
  815. X#    on systems that have the parallel make feature.
  816. Xobjects:        $& $(UTIL_OBJ)
  817. X
  818. Xinstall:        $(INSTALL_LIST) $(DEST)/wnewmail
  819. X
  820. Xuninstall:        
  821. X            $(RM) $(INSTALL_LIST) $(DEST)/wnewmail
  822. X
  823. X#    This is the only target that gets installed even if not out-of-date
  824. X#    with respect the files from which it is installed.
  825. Xrmt-install:        rmt-defined
  826. X            -$(MV) $(DEST)/answer $(DEST)/answer.old
  827. X            -$(MV) $(DEST)/arepdaemon $(DEST)/arepdaemon.old
  828. X            -$(MV) $(DEST)/autoreply $(DEST)/autoreply.old
  829. X            -$(MV) $(DEST)/checkalias $(DEST)/checkalias.old
  830. X            -$(MV) $(DEST)/fastmail $(DEST)/fastmail.old
  831. X            -$(MV) $(DEST)/frm $(DEST)/frm.old
  832. X            -$(MV) $(DEST)/listalias $(DEST)/listalias.old
  833. X            -$(MV) $(DEST)/messages $(DEST)/messages.old
  834. X            -$(MV) $(DEST)/newalias $(DEST)/newalias.old
  835. X            -$(MV) $(DEST)/newmail $(DEST)/newmail.old
  836. X            -$(MV) $(DEST)/printmail $(DEST)/printmail.old
  837. X            -$(MV) $(DEST)/readmsg $(DEST)/readmsg.old
  838. X            -$(MV) $(DEST)/wnewmail $(DEST)/wnewmail.old
  839. X            -$(RM) $(DEST)/answer.old
  840. X            -$(RM) $(DEST)/arepdaemon.old
  841. X            -$(RM) $(DEST)/autoreply.old
  842. X            -$(RM) $(DEST)/checkalias.old
  843. X            -$(RM) $(DEST)/fastmail.old
  844. X            -$(RM) $(DEST)/frm.old
  845. X            -$(RM) $(DEST)/listalias.old
  846. X            -$(RM) $(DEST)/messages.old
  847. X            -$(RM) $(DEST)/newalias.old
  848. X            -$(RM) $(DEST)/newmail.old
  849. X            -$(RM) $(DEST)/printmail.old
  850. X            -$(RM) $(DEST)/readmsg.old
  851. X            -$(RM) $(DEST)/wnewmail.old
  852. X            $(CP) $(REMOTE_LIST) $(DEST)
  853. X            $(LN) $(REMOTE)$(DEST)/wnewmail $(DEST)
  854. X            $(CHMOD) a+rx $(INSTALL_LIST)
  855. X
  856. Xrmt-defined:
  857. X    @(if [ "$(REMOTE)" = "" ];\
  858. X      then\
  859. X        $(ECHO) "You need to define 'REMOTE' as the remote file system";\
  860. X        $(ECHO) "for this particular command. The easiest way to do this";\
  861. X        $(ECHO) "to type:";\
  862. X        $(ECHO) "        make REMOTE=<remote file system> rmt-install";\
  863. X        exit 1;\
  864. X      fi);
  865. X
  866. X#    This rule allows us to put lint output for each program on the
  867. X#    same file, but make sure we start off fresh each time.
  868. Xlint:            
  869. X            $(RM) LINT.OUT; $(MAKE) -$(MAKEFLAGS) $(LINT_LIST)
  870. X
  871. Xclean:            
  872. X            $(RM) $(UTIL_OBJ) $(BINARY_LIST)
  873. X
  874. X# Dependencies and rules
  875. X#    Dependencies and rules for compiling and linting C programs
  876. X$(BIN)/answer:        $(ANSWER_OBJ)
  877. X            $(CC) $(LFLAGS) -o $@ $(ANSWER_OBJ) $(LIB2)
  878. X
  879. Xanswer_lint:        $(ANSWER_SRC)
  880. X            $(LINT) $(LINTFLAGS) $(ANSWER_SRC) >> LINT.OUT
  881. X
  882. X$(BIN)/arepdaemon:    $(AREPDAEMON_OBJ)
  883. X            $(CC) $(LFLAGS) -o $@ $(AREPDAEMON_OBJ) $(LIB2)
  884. X
  885. Xarepdaemon_lint:    $(AREPDAEMON_SRC)
  886. X            $(LINT) $(LINTFLAGS) $(AREPDAEMON_SRC) >> LINT.OUT
  887. X
  888. X$(BIN)/autoreply:    $(AUTOREPLY_OBJ)
  889. X            $(CC) $(LFLAGS) -o $@ $(AUTOREPLY_OBJ) $(LIB2)
  890. X
  891. Xautoreply_lint:        $(AUTOREPLY_SRC)
  892. X            $(LINT) $(LINTFLAGS) $(AUTOREPLY_SRC) >> LINT.OUT
  893. X
  894. X$(BIN)/fastmail:    $(FASTMAIL_OBJ)
  895. X            $(CC) $(LFLAGS) -o $@ $(FASTMAIL_OBJ) $(LIB2)
  896. X
  897. Xfastmail_lint:        $(FASTMAIL_SRC)
  898. X            $(LINT) $(LINTFLAGS) $(FASTMAIL_SRC) >> LINT.OUT
  899. X
  900. X$(BIN)/frm:        $(FRM_OBJ)
  901. X            $(CC) $(LFLAGS) -o $@ $(FRM_OBJ) $(LIB2)
  902. X
  903. Xfrm_lint:        $(FRM_SRC)
  904. X            $(LINT) $(LINTFLAGS) $(FRM_SRC) >> LINT.OUT
  905. X
  906. X$(BIN)/listalias:    $(LISTALIAS_OBJ)
  907. X            $(CC) $(LFLAGS) -o $@ $(LISTALIAS_OBJ) $(LIB2)
  908. X
  909. Xlistalias_lint:        $(LISTALIAS_SRC)
  910. X            $(LINT) $(LINTFLAGS) $(LISTALIAS_SRC) >> LINT.OUT
  911. X
  912. X$(BIN)/newalias:    $(NEWALIAS_OBJ)
  913. X            $(CC) $(LFLAGS) -o $@ $(NEWALIAS_OBJ) $(LIB2)
  914. X
  915. Xnewalias_lint:        $(NEWALIAS_SRC)
  916. X            $(LINT) $(LINTFLAGS) $(NEWALIAS_SRC) >> LINT.OUT
  917. X
  918. X$(BIN)/newmail:        $(NEWMAIL_OBJ)
  919. X            $(CC) $(LFLAGS) -o $@ $(NEWMAIL_OBJ) $(LIB2)
  920. X
  921. Xnewmail_lint:        $(NEWMAIL_SRC)
  922. X            $(LINT) $(LINTFLAGS) $(NEWMAIL_SRC) >> LINT.OUT
  923. X
  924. X$(BIN)/readmsg:        $(READMSG_OBJ)
  925. X            $(CC) $(LFLAGS) -o $@ $(READMSG_OBJ) $(LIB2)
  926. X
  927. Xreadmsg_lint:        $(READMSG_SRC)
  928. X            $(LINT) $(LINTFLAGS) $(READMSG_SRC) >> LINT.OUT
  929. X
  930. X
  931. X#    Rules to make shell scripts in bin directory
  932. X$(BIN)/checkalias:    checkalias
  933. X            $(CP) $? $@
  934. X            $(CHMOD) u+w,a+rx $@
  935. X
  936. X$(BIN)/messages:    messages
  937. X            $(CP) $? $@
  938. X            $(CHMOD) u+w,a+rx $@
  939. X
  940. X$(BIN)/printmail:    printmail
  941. X            $(CP) $? $@
  942. X            $(CHMOD) u+w,a+rx $@
  943. X
  944. X#    Dependencies of header files upon other header files they include
  945. X$(INCLDIR)/defs.h:    $(INCLDIR)/../config.h $(INCLDIR)/sysdefs.h
  946. X            $(CHMOD) u+w $@
  947. X            $(TOUCH) $@
  948. X
  949. X$(INCLDIR)/elm.h:    $(INCLDIR)/curses.h $(INCLDIR)/defs.h
  950. X            $(CHMOD) u+w $@
  951. X            $(TOUCH) $@
  952. X
  953. X$(INCLDIR)/headers.h:    $(INCLDIR)/curses.h $(INCLDIR)/defs.h
  954. X            $(CHMOD) u+w $@
  955. X            $(TOUCH) $@
  956. X
  957. X#    Rules to make objects from src directory
  958. X../src/opt_utils.o:
  959. X            cd ../src; $(MAKE) -$(MAKEFLAGS) opt_utils.o
  960. X
  961. X../src/string2.o:
  962. X            cd ../src; $(MAKE) -$(MAKEFLAGS) string2.o
  963. X
  964. X../src/validname.o:
  965. X            cd ../src; $(MAKE) -$(MAKEFLAGS) validname.o
  966. X
  967. X#    Dependencies of C object files
  968. Xanswer.o:    $(INCLDIR)/defs.h
  969. Xarepdaem.o:    $(INCLDIR)/defs.h
  970. Xautoreply.o:    $(INCLDIR)/defs.h
  971. Xexpand.o:    $(INCLDIR)/defs.h
  972. Xfastmail.o:    $(INCLDIR)/defs.h $(INCLDIR)/patchlevel.h
  973. Xfrom.o:        $(INCLDIR)/defs.h
  974. Xlistalias.o:    $(INCLDIR)/defs.h $(INCLDIR)/sysdefs.h
  975. Xnewalias.o:    $(INCLDIR)/defs.h $(INCLDIR)/sysdefs.h
  976. Xnewmail.o:    $(INCLDIR)/defs.h
  977. Xreadmsg.o:    $(INCLDIR)/defs.h
  978. X
  979. X#    Dependencies and rules for installing programs from bin directory
  980. X$(DEST)/answer:        $(BIN)/answer
  981. X            -$(MV) $@ $@.old
  982. X            -$(RM) $@.old
  983. X            $(CP) $? $@
  984. X            $(CHMOD) a+x $@
  985. X
  986. X$(DEST)/arepdaemon:    $(BIN)/arepdaemon
  987. X            -$(MV) $@ $@.old
  988. X            -$(RM) $@.old
  989. X            $(CP) $? $@
  990. X            $(CHMOD) a+x $@
  991. X
  992. X$(DEST)/autoreply:    $(BIN)/autoreply
  993. X            -$(MV) $@ $@.old
  994. X            -$(RM) $@.old
  995. X            $(CP) $? $@
  996. X            $(CHMOD) a+x $@
  997. X            $(CHMOD) u+s $@
  998. X
  999. X$(DEST)/checkalias:    $(BIN)/checkalias
  1000. X            -$(MV) $@ $@.old
  1001. X            -$(RM) $@.old
  1002. X            $(CP) $? $@
  1003. X            $(CHMOD) a+rx $@
  1004. X
  1005. X$(DEST)/fastmail:    $(BIN)/fastmail
  1006. X            -$(MV) $@ $@.old
  1007. X            -$(RM) $@.old
  1008. X            $(CP) $? $@
  1009. X            $(CHMOD) a+x $@
  1010. X
  1011. X$(DEST)/frm:        $(BIN)/frm
  1012. X            -$(MV) $@ $@.old
  1013. X            -$(RM) $@.old
  1014. X            $(CP) $? $@
  1015. X            $(CHMOD) a+x $@
  1016. X
  1017. X$(DEST)/listalias:    $(BIN)/listalias
  1018. X            -$(MV) $@ $@.old
  1019. X            -$(RM) $@.old
  1020. X            $(CP) $? $@
  1021. X            $(CHMOD) a+x $@
  1022. X
  1023. X$(DEST)/messages:    $(BIN)/messages
  1024. X            -$(MV) $@ $@.old
  1025. X            -$(RM) $@.old
  1026. X            $(CP) $? $@
  1027. X            $(CHMOD) a+rx $@
  1028. X
  1029. X$(DEST)/newalias:    $(BIN)/newalias
  1030. X            -$(MV) $@ $@.old
  1031. X            -$(RM) $@.old
  1032. X            $(CP) $? $@
  1033. X            $(CHMOD) a+x $@
  1034. X
  1035. X$(DEST)/newmail:    $(BIN)/newmail
  1036. X            -$(MV) $@ $@.old
  1037. X            -$(RM) $@.old
  1038. X            $(RM) $@
  1039. X            $(CP) $? $@
  1040. X            $(CHMOD) a+x $@
  1041. X
  1042. X$(DEST)/printmail:    $(BIN)/printmail
  1043. X            -$(MV) $@ $@.old
  1044. X            -$(RM) $@.old
  1045. X            $(CP) $? $@
  1046. X            $(CHMOD) a+rx $@
  1047. X
  1048. X$(DEST)/readmsg:    $(BIN)/readmsg
  1049. X            -$(MV) $@ $@.old
  1050. X            -$(RM) $@.old
  1051. X            $(CP) $? $@
  1052. X            $(CHMOD) a+x $@
  1053. X
  1054. X$(DEST)/wnewmail:    $(DEST)/newmail
  1055. X            -$(MV) $@ $@.old
  1056. X            -$(RM) $@.old
  1057. X            $(RM) $@
  1058. X            $(LN) $? $@
  1059. X
  1060. X!NO!SUBS!
  1061. SHAR_EOF
  1062. chmod 0444 utils/Makefile.SH || echo "restore of utils/Makefile.SH fails"
  1063. echo "x - extracting utils/answer.c (Text)"
  1064. sed 's/^X//' << 'SHAR_EOF' > utils/answer.c &&
  1065. X
  1066. Xstatic char rcsid[] = "@(#)$Id: answer.c,v 2.5 89/03/25 21:47:38 syd Exp $";
  1067. X
  1068. X/*******************************************************************************
  1069. X *  The Elm Mail System  -  $Revision: 2.5 $   $State: Exp $
  1070. X *
  1071. X *             Copyright (c) 1986, 1987 Dave Taylor
  1072. X *             Copyright (c) 1988, 1989 USENET Community Trust
  1073. X *******************************************************************************
  1074. X * Bug reports, patches, comments, suggestions should be sent to:
  1075. X *
  1076. X *    Syd Weinstein, Elm Coordinator
  1077. X *    elm@dsinc.UUCP            dsinc!elm
  1078. X *
  1079. X *******************************************************************************
  1080. X * $Log:    answer.c,v $
  1081. X * Revision 2.5  89/03/25  21:47:38  syd
  1082. X * Initial 2.2 Release checkin
  1083. X * 
  1084. X *
  1085. X ******************************************************************************/
  1086. X
  1087. X/** This program is a phone message transcription system, and
  1088. X    is designed for secretaries and the like, to allow them to
  1089. X    painlessly generate electronic mail instead of paper forms.
  1090. X
  1091. X    Note: this program ONLY uses the local alias file, and does not
  1092. X      even read in the system alias file at all.
  1093. X
  1094. X**/
  1095. X
  1096. X#include <stdio.h>
  1097. X#include <fcntl.h>
  1098. X#include <ctype.h>
  1099. X
  1100. X#include "defs.h"            /* ELM system definitions      */
  1101. X
  1102. X#define  ELM        "elm"        /* where the elm program lives */
  1103. X
  1104. X#define  answer_temp_file    "/tmp/answer."
  1105. X
  1106. Xstatic char ident[] = { WHAT_STRING };
  1107. X
  1108. Xstruct alias_rec user_hash_table  [MAX_UALIASES];
  1109. X
  1110. Xint user_data;        /* fileno of user data file   */
  1111. X
  1112. Xchar *expand_group(), *get_alias_address(), *get_token(), *strip_parens();
  1113. X
  1114. Xmain()
  1115. X{
  1116. X    FILE *fd;
  1117. X    char *address, buffer[LONG_STRING], tempfile[SLEN], *cp;
  1118. X    char  name[SLEN], user_name[SLEN];
  1119. X    int   msgnum = 0, eof;
  1120. X    
  1121. X    read_alias_files();
  1122. X
  1123. X    while (1) {
  1124. X      if (msgnum > 9999) msgnum = 0;
  1125. X    
  1126. X      printf("\n-------------------------------------------------------------------------------\n");
  1127. X
  1128. Xprompt:   printf("\nMessage to: ");
  1129. X      if (fgets(user_name, SLEN, stdin) == NULL || user_name[0] == '\0')
  1130. X        goto prompt;
  1131. X      
  1132. X      cp = &user_name[strlen(user_name)-1];
  1133. X      if(*cp == '\n') *cp = '\0';
  1134. X
  1135. X      if ((strcmp(user_name,"quit") == 0) ||
  1136. X          (strcmp(user_name,"exit") == 0) ||
  1137. X          (strcmp(user_name,"done") == 0) ||
  1138. X          (strcmp(user_name,"bye")  == 0))
  1139. X         exit(0);
  1140. X
  1141. X      if (translate(user_name, name) == 0)
  1142. X        goto prompt;
  1143. X
  1144. X      address = get_alias_address(name, 1, 0);
  1145. X
  1146. X      printf("address '%s'\n", address);
  1147. X
  1148. X      if (address == NULL || strlen(address) == 0) {
  1149. X        printf("Sorry, could not find '%s' [%s] in list!\n", user_name, 
  1150. X           name);
  1151. X        goto prompt;
  1152. X      }
  1153. X
  1154. X      sprintf(tempfile, "%s%d", answer_temp_file, msgnum++);
  1155. X
  1156. X      if ((fd = fopen(tempfile,"w")) == NULL)
  1157. X        exit(printf("** Fatal Error: could not open %s to write\n",
  1158. X         tempfile));
  1159. X
  1160. X
  1161. X      printf("\nEnter message for %s ending with a blank line.\n\n", 
  1162. X         user_name);
  1163. X
  1164. X      fprintf(fd,"\n\n");
  1165. X
  1166. X      do {
  1167. X       printf("> ");
  1168. X       if (! (eof = (fgets(buffer, SLEN, stdin) == NULL))) 
  1169. X         fprintf(fd, "%s", buffer);
  1170. X      } while (! eof && strlen(buffer) > 1);
  1171. X    
  1172. X      fclose(fd);
  1173. X      sprintf(buffer, 
  1174. X         "((%s -s \"While You Were Out\" %s ; %s %s) & ) < %s > /dev/null",
  1175. X         ELM, strip_parens(address), remove_cmd, tempfile, tempfile);
  1176. X
  1177. X      system(buffer);
  1178. X    }
  1179. X}
  1180. X
  1181. Xint
  1182. Xtranslate(fullname, name)
  1183. Xchar *fullname, *name;
  1184. X{
  1185. X    /** translate fullname into name..
  1186. X           'first last'  translated to first_initial - underline - last
  1187. X           'initial last' translated to initial - underline - last
  1188. X        Return 0 if error.
  1189. X    **/
  1190. X    register int i, lastname = 0;
  1191. X
  1192. X    for (i=0; i < strlen(fullname); i++) {
  1193. X
  1194. X      if (isupper(fullname[i]))
  1195. X         fullname[i] = tolower(fullname[i]);
  1196. X
  1197. X      if (fullname[i] == ' ') 
  1198. X        if (lastname) {
  1199. X          printf(
  1200. X          "** Can't have more than 'FirstName LastName' as address!\n");
  1201. X          return(0);
  1202. X        }
  1203. X        else
  1204. X          lastname = i+1;
  1205. X    
  1206. X    }
  1207. X
  1208. X    if (lastname) 
  1209. X      sprintf(name, "%c_%s", fullname[0], (char *) fullname + lastname);
  1210. X    else
  1211. X      strcpy(name, fullname);
  1212. X
  1213. X    return(1);
  1214. X}
  1215. X
  1216. X        
  1217. Xread_alias_files()
  1218. X{
  1219. X    /** read the user alias file **/
  1220. X
  1221. X    char fname[SLEN];
  1222. X    int  hash;
  1223. X
  1224. X    sprintf(fname,  "%s/.elm/aliases.hash", getenv("HOME")); 
  1225. X
  1226. X    if ((hash = open(fname, O_RDONLY)) == -1) 
  1227. X      exit(printf("** Fatal Error: Could not open %s!\n", fname));
  1228. X
  1229. X    read(hash, user_hash_table, sizeof user_hash_table);
  1230. X    close(hash);
  1231. X
  1232. X    sprintf(fname,  "%s/.elm/aliases.data", getenv("HOME")); 
  1233. X
  1234. X    if ((user_data = open(fname, O_RDONLY)) == -1) 
  1235. X      return;
  1236. X}
  1237. X
  1238. Xchar *get_alias_address(name, mailing, depth)
  1239. Xchar *name;
  1240. Xint   mailing, depth;
  1241. X{
  1242. X    /** return the line from either datafile that corresponds 
  1243. X        to the specified name.  If 'mailing' specified, then
  1244. X        fully expand group names.  Returns NULL if not found.
  1245. X        Depth is the nesting depth, and varies according to the
  1246. X        nesting level of the routine.  **/
  1247. X
  1248. X    static char buffer[VERY_LONG_STRING];
  1249. X    int    loc;
  1250. X
  1251. X    if ((loc = find(name, user_hash_table, MAX_UALIASES)) >= 0) {
  1252. X      lseek(user_data, user_hash_table[loc].byte, 0L);
  1253. X      get_line(user_data, buffer);
  1254. X      if (buffer[0] == '!' && mailing)
  1255. X        return( (char *) expand_group(buffer, depth));
  1256. X      else
  1257. X        return( (char *) buffer);
  1258. X    }
  1259. X    
  1260. X    return( (char *) NULL);
  1261. X}
  1262. X
  1263. Xchar *expand_group(members, depth)
  1264. Xchar *members;
  1265. Xint   depth;
  1266. X{
  1267. X    /** given a group of names separated by commas, this routine
  1268. X        will return a string that is the full addresses of each
  1269. X        member separated by spaces.  Depth is the current recursion
  1270. X        depth of the expansion (for the 'get_token' routine) **/
  1271. X
  1272. X    char   buffer[VERY_LONG_STRING];
  1273. X    char   buf[LONG_STRING], *word, *address, *bufptr;
  1274. X
  1275. X    strcpy(buf, members);     /* parameter safety! */
  1276. X    buffer[0] = '\0';    /* nothing in yet!   */
  1277. X    bufptr = (char *) buf;    /* grab the address  */
  1278. X    depth++;        /* one more deeply into stack */
  1279. X
  1280. X    while ((word = (char *) get_token(bufptr, "!, ", depth)) != NULL) {
  1281. X      if ((address = (char *) get_alias_address(word, 1, depth)) == NULL) {
  1282. X        fprintf(stderr, "Alias %s not found for group expansion!", word);
  1283. X        return( (char *) NULL);
  1284. X      }
  1285. X      else if (strcmp(buffer,address) != 0) {
  1286. X        sprintf(buffer,"%s %s", buffer, address);
  1287. X      }
  1288. X
  1289. X      bufptr = NULL;
  1290. X    }
  1291. X
  1292. X    return( (char *) buffer);
  1293. X}
  1294. X
  1295. Xint
  1296. Xfind(word, table, size)
  1297. Xchar *word;
  1298. Xstruct alias_rec table[];
  1299. Xint size;
  1300. X{
  1301. X    /** find word and return loc, or -1 **/
  1302. X    register int loc;
  1303. X    
  1304. X    if (strlen(word) > 20)
  1305. X      exit(printf("Bad alias name: %s.  Too long.\n", word));
  1306. X
  1307. X    loc = hash_it(word, size);
  1308. X
  1309. X    while (strcmp(word, table[loc].name) != 0) {
  1310. X      if (table[loc].name[0] == '\0') 
  1311. X        return(-1);
  1312. X      loc = (loc + 1) % size; 
  1313. X    }
  1314. X
  1315. X    return(loc);
  1316. X}
  1317. X
  1318. Xint
  1319. Xhash_it(string, table_size)
  1320. Xchar *string;
  1321. Xint   table_size;
  1322. X{
  1323. X    /** compute the hash function of the string, returning
  1324. X        it (mod table_size) **/
  1325. X
  1326. X    register int i, sum = 0;
  1327. X    
  1328. X    for (i=0; string[i] != '\0'; i++)
  1329. X      sum += (int) string[i];
  1330. X
  1331. X    return(sum % table_size);
  1332. X}
  1333. X
  1334. Xget_line(fd, buffer)
  1335. Xint fd;
  1336. Xchar *buffer;
  1337. X{
  1338. X    /* read from file fd.  End read upon reading either 
  1339. X       EOF or '\n' character (this is where it differs 
  1340. X       from a straight 'read' command!) */
  1341. X
  1342. X    register int i= 0;
  1343. X    char     ch;
  1344. X
  1345. X    while (read(fd, &ch, 1) > 0)
  1346. X      if (ch == '\n' || ch == '\r') {
  1347. X        buffer[i] = 0;
  1348. X        return;
  1349. X      }
  1350. X      else
  1351. X        buffer[i++] = ch;
  1352. X}
  1353. X
  1354. Xprint_long(buffer, init_len)
  1355. Xchar *buffer;
  1356. Xint   init_len;
  1357. X{
  1358. X    /** print buffer out, 80 characters (or less) per line, for
  1359. X        as many lines as needed.  If 'init_len' is specified, 
  1360. X        it is the length that the first line can be.
  1361. X    **/
  1362. X
  1363. X    register int i, loc=0, space, length; 
  1364. X
  1365. X    /* In general, go to 80 characters beyond current character
  1366. X       being processed, and then work backwards until space found! */
  1367. X
  1368. X    length = init_len;
  1369. X
  1370. X    do {
  1371. X      if (strlen(buffer) > loc + length) {
  1372. X        space = loc + length;
  1373. X        while (buffer[space] != ' ' && space > loc + 50) space--;
  1374. X        for (i=loc;i <= space;i++)
  1375. X          putchar(buffer[i]);
  1376. X        putchar('\n');
  1377. X        loc = space;
  1378. X      }
  1379. X      else {
  1380. X        for (i=loc;i < strlen(buffer);i++)
  1381. X          putchar(buffer[i]);
  1382. X        putchar('\n');
  1383. X        loc = strlen(buffer);
  1384. X      }
  1385. X      length = 80;
  1386. X    } while (loc < strlen(buffer));
  1387. X}
  1388. X
  1389. X/****
  1390. X     The following is a newly chopped version of the 'strtok' routine
  1391. X  that can work in a recursive way (up to 20 levels of recursion) by
  1392. X  changing the character buffer to an array of character buffers....
  1393. X****/
  1394. X
  1395. X#define MAX_RECURSION        20        /* up to 20 deep recursion */
  1396. X
  1397. X#undef  NULL
  1398. X#define NULL            (char *) 0    /* for this routine only   */
  1399. X
  1400. Xextern int strspn();
  1401. Xextern char *strpbrk();
  1402. X
  1403. Xchar *get_token(string, sepset, depth)
  1404. Xchar *string, *sepset;
  1405. Xint  depth;
  1406. X{
  1407. X
  1408. X    /** string is the string pointer to break up, sepstr are the
  1409. X        list of characters that can break the line up and depth
  1410. X        is the current nesting/recursion depth of the call **/
  1411. X
  1412. X    register char    *p, *q, *r;
  1413. X    static char    *savept[MAX_RECURSION];
  1414. X
  1415. X    /** is there space on the recursion stack? **/
  1416. X
  1417. X    if (depth >= MAX_RECURSION) {
  1418. X     fprintf(stderr,"Error: Get_token calls nested greated than %d deep!\n",
  1419. X            MAX_RECURSION);
  1420. X     exit(1);
  1421. X    }
  1422. X
  1423. X    /* set up the pointer for the first or subsequent call */
  1424. X    p = (string == NULL)? savept[depth]: string;
  1425. X
  1426. X    if(p == 0)        /* return if no tokens remaining */
  1427. X        return(NULL);
  1428. X
  1429. X    q = p + strspn(p, sepset);    /* skip leading separators */
  1430. X
  1431. X    if (*q == '\0')        /* return if no tokens remaining */
  1432. X        return(NULL);
  1433. X
  1434. X    if ((r = strpbrk(q, sepset)) == NULL)    /* move past token */
  1435. X        savept[depth] = 0;    /* indicate this is last token */
  1436. X    else {
  1437. X        *r = '\0';
  1438. X        savept[depth] = ++r;
  1439. X    }
  1440. X    return(q);
  1441. X}
  1442. X
  1443. Xchar *strip_parens(string)
  1444. Xchar *string;
  1445. X{
  1446. X    /** Return string with all parenthesized information removed.
  1447. X        This is a non-destructive algorithm... **/
  1448. X
  1449. X    static char  buffer[LONG_STRING];
  1450. X    register int i, depth = 0, buffer_index = 0;
  1451. X
  1452. X    for (i=0; i < strlen(string); i++) {
  1453. X      if (string[i] == '(')
  1454. X        depth++;
  1455. X      else if (string[i] == ')') 
  1456. X        depth--;
  1457. X      else if (depth == 0)
  1458. X        buffer[buffer_index++] = string[i];
  1459. X    }
  1460. X    
  1461. X    buffer[buffer_index] = '\0';
  1462. X
  1463. X    return( (char *) buffer);
  1464. X}
  1465. SHAR_EOF
  1466. chmod 0444 utils/answer.c || echo "restore of utils/answer.c fails"
  1467. echo "x - extracting utils/arepdaem.c (Text)"
  1468. sed 's/^X//' << 'SHAR_EOF' > utils/arepdaem.c &&
  1469. X
  1470. Xstatic char rcsid[] = "@(#)$Id: arepdaem.c,v 2.6 89/03/25 21:47:39 syd Exp $";
  1471. X
  1472. X/*******************************************************************************
  1473. X *  The Elm Mail System  -  $Revision: 2.6 $   $State: Exp $
  1474. X *
  1475. X *             Copyright (c) 1986, 1987 Dave Taylor
  1476. X *             Copyright (c) 1988, 1989 USENET Community Trust
  1477. X *******************************************************************************
  1478. X * Bug reports, patches, comments, suggestions should be sent to:
  1479. X *
  1480. X *    Syd Weinstein, Elm Coordinator
  1481. X *    elm@dsinc.UUCP            dsinc!elm
  1482. X *
  1483. X *******************************************************************************
  1484. X * $Log:    arepdaem.c,v $
  1485. X * Revision 2.6  89/03/25  21:47:39  syd
  1486. X * Initial 2.2 Release checkin
  1487. X * 
  1488. X *
  1489. X ******************************************************************************/
  1490. X
  1491. X/** Keep track of mail as it arrives, and respond by sending a 'recording'
  1492. X    file to the sender as new mail is received.
  1493. X
  1494. X    Note: the user program that interacts with this program is the
  1495. X    'autoreply' program and that should be consulted for further
  1496. X    usage information.
  1497. X
  1498. X    This program is part of the 'autoreply' system, and is designed
  1499. X    to run every hour and check all mailboxes listed in the file 
  1500. X    "/etc/autoreply.data", where the data is in the form:
  1501. X
  1502. X    username    replyfile    current-mailfile-size
  1503. X
  1504. X    To avoid a flood of autoreplies, this program will NOT reply to mail 
  1505. X    that contains header "X-Mailer: fastmail".  Further, each time the 
  1506. X    program responds to mail, the 'mailfile size' entry is updated in
  1507. X    the file /etc/autoreply.data to allow the system to be brought 
  1508. X    down and rebooted without any loss of data or duplicate messages.
  1509. X
  1510. X    This daemon also uses a lock semaphore file, /usr/spool/uucp/LCK..arep,
  1511. X    to ensure that more than one copy of itself is never running.  For this
  1512. X    reason, it is recommended that this daemon be started up each morning
  1513. X    from cron, since it will either start since it's needed or simply see
  1514. X    that the file is there and disappear.
  1515. X
  1516. X    Since this particular program is the main daemon answering any
  1517. X    number of different users, it must be run with uid root.
  1518. X**/
  1519. X
  1520. X#include <stdio.h>
  1521. X#include "defs.h"
  1522. X
  1523. X#ifdef BSD
  1524. X# include <sys/time.h>
  1525. X#else
  1526. X# include <time.h>
  1527. X#endif
  1528. X
  1529. X#include <sys/types.h>
  1530. X#include <sys/stat.h>
  1531. X
  1532. Xstatic char ident[] = { WHAT_STRING };
  1533. X
  1534. X#define arep_lock_file    "/usr/spool/uucp/LCK..arep"
  1535. X
  1536. X#define autoreply_file    "/etc/autoreply.data"
  1537. X#define fastmail    "/usr/local/bin/fastmail"
  1538. X
  1539. X#define logfile        "/etc/autoreply.log"    /* first choice   */
  1540. X#define logfile2    "/tmp/autoreply.log"    /* second choice  */
  1541. X
  1542. X#define BEGINNING    0        /* see fseek(3S) for info */
  1543. X#define SLEEP_TIME    3600        /* run once an hour       */
  1544. X#define MAX_PEOPLE    20        /* max number in program  */
  1545. X
  1546. X#define EXISTS        00        /* lock file exists??     */
  1547. X#define MODE        0777        /* lockfile creation mode */
  1548. X
  1549. X#define remove_return(s)    if (strlen(s) > 0) { \
  1550. X                      if (s[strlen(s)-1] == '\n') \
  1551. X                    s[strlen(s)-1] = '\0'; \
  1552. X                        }
  1553. X
  1554. Xstruct replyrec {
  1555. X    char     username[NLEN];        /* login name of user */
  1556. X    char    mailfile[SLEN];        /* name of mail file  */
  1557. X    char    replyfile[SLEN];    /* name of reply file */
  1558. X    long    mailsize;        /* mail file size     */
  1559. X    int     in_list;        /* for new replies    */
  1560. X      } reply_table[MAX_PEOPLE];
  1561. X
  1562. XFILE  *logfd;                /* logfile (log action)   */
  1563. Xlong  autoreply_size = 0L;        /* size of autoreply file */
  1564. Xint   active = 0;            /* # of people 'enrolled' */
  1565. X
  1566. XFILE  *open_logfile();            /* forward declaration    */
  1567. X
  1568. Xlong  bytes();                /*       ditto           */
  1569. X
  1570. Xmain()
  1571. X{
  1572. X    long size;
  1573. X    int  person, data_changed;
  1574. X
  1575. X    if (! lock())
  1576. X      exit(0);    /* already running! */
  1577. X
  1578. X    if (fork()) exit(0);
  1579. X
  1580. X    while (1) {
  1581. X
  1582. X      logfd = open_logfile();    /* open the log */
  1583. X
  1584. X      /* 1. check to see if autoreply table has changed.. */
  1585. X
  1586. X      if ((size = bytes(autoreply_file)) != autoreply_size) {
  1587. X        read_autoreply_file(); 
  1588. X        autoreply_size = size;
  1589. X      }
  1590. X
  1591. X      /* 2. now for each active person... */
  1592. X    
  1593. X      data_changed = 0;
  1594. X
  1595. X      for (person = 0; person < active; person++) {
  1596. X        if ((size = bytes(reply_table[person].mailfile)) != 
  1597. X        reply_table[person].mailsize) {
  1598. X          if (size > reply_table[person].mailsize)
  1599. X            read_newmail(person);
  1600. X          /* else mail removed - resync */
  1601. X          reply_table[person].mailsize = size;
  1602. X          data_changed++;
  1603. X        }
  1604. X      }
  1605. X
  1606. X      /* 3. if data changed, update autoreply file */
  1607. X
  1608. X      if (data_changed)
  1609. X        update_autoreply_file();
  1610. X
  1611. X      close_logfile();        /* close the logfile again */
  1612. X
  1613. X      /* 4. Go to sleep...  */
  1614. X
  1615. X      sleep(SLEEP_TIME);
  1616. X    }
  1617. X}
  1618. X
  1619. Xint
  1620. Xread_autoreply_file()
  1621. X{
  1622. X    /** We're here because the autoreply file has changed size!!  It
  1623. X        could either be because someone has been added or because
  1624. X        someone has been removed...since the list will always be in
  1625. X        order (nice, eh?) we should have a pretty easy time of it...
  1626. X    **/
  1627. X
  1628. X    FILE *file;
  1629. X    char username[SLEN],     replyfile[SLEN];
  1630. X    int  person;
  1631. X     long size;
  1632. X    
  1633. X    log("Autoreply data file has changed!  Reading...");
  1634. X
  1635. X    if ((file = fopen(autoreply_file,"r")) == NULL) {
  1636. X      log("No-one is using autoreply...");
  1637. X      return(0);
  1638. X    }
  1639. X    
  1640. X    for (person = 0; person < active; person++)
  1641. X      reply_table[person].in_list = 0;
  1642. X    
  1643. X    while (fscanf(file, "%s %s %dl", username, replyfile, &size) != EOF) {
  1644. X      /* check to see if this person is already in the list */
  1645. X      if ((person = in_list(username)) != -1) {
  1646. X        reply_table[person].in_list = 1;
  1647. X        reply_table[person].mailsize = size;     /* sync */
  1648. X      }
  1649. X      else {     /* if not, add them */
  1650. X        if (active == MAX_PEOPLE) {
  1651. X          unlock();
  1652. X          exit(log("Couldn't add %s - already at max people!", 
  1653. X                 username));
  1654. X        }
  1655. X        log("adding %s to the active list", username);
  1656. X        strcpy(reply_table[active].username, username);
  1657. X        sprintf(reply_table[active].mailfile, "%s%s", mailhome, username);
  1658. X        strcpy(reply_table[active].replyfile, replyfile);
  1659. X        reply_table[active].mailsize = size;
  1660. X        reply_table[active].in_list = 1;    /* obviously! */
  1661. X        active++;
  1662. X      }
  1663. X    }
  1664. X
  1665. X    /** now check to see if anyone has been removed... **/
  1666. X
  1667. X    for (person = 0; person < active; person++)
  1668. X      if (reply_table[person].in_list == 0) {
  1669. X         log("removing %s from the active list", 
  1670. X          reply_table[person].username);
  1671. X        strcpy(reply_table[person].username, 
  1672. X           reply_table[active-1].username);
  1673. X        strcpy(reply_table[person].mailfile, 
  1674. X           reply_table[active-1].mailfile);
  1675. X        strcpy(reply_table[person].replyfile, 
  1676. X           reply_table[active-1].replyfile);
  1677. X        reply_table[person].mailsize = reply_table[active-1].mailsize;
  1678. X        active--;
  1679. X      }
  1680. X}
  1681. X
  1682. Xupdate_autoreply_file()
  1683. X{
  1684. X    /** update the entries in the autoreply file... **/
  1685. X
  1686. X    FILE *file;
  1687. X    register int person;
  1688. X
  1689. X    if ((file = fopen(autoreply_file,"w")) == NULL) {
  1690. X          log("Couldn't update autoreply file!");
  1691. X      return;
  1692. X    }
  1693. X
  1694. X    for (person = 0; person < active; person++)
  1695. X      fprintf(file, "%s %s %ld\n",
  1696. X          reply_table[person].username,
  1697. X          reply_table[person].replyfile,
  1698. X          reply_table[person].mailsize);
  1699. X
  1700. X    fclose(file);
  1701. X
  1702. X/*    printf("updated autoreply file\n"); */
  1703. X    autoreply_size = bytes(autoreply_file);
  1704. X}
  1705. X
  1706. Xint
  1707. Xin_list(name)
  1708. Xchar *name;
  1709. X{
  1710. X    /** search the current active reply list for the specified username.
  1711. X        return the index if found, or '-1' if not. **/
  1712. X
  1713. X    register int iindex;
  1714. X
  1715. X    for (iindex = 0; iindex < active; iindex++)
  1716. X      if (strcmp(name, reply_table[iindex].username) == 0)
  1717. X        return(iindex);
  1718. X    
  1719. X    return(-1);
  1720. X}
  1721. X
  1722. Xread_newmail(person)
  1723. Xint person;
  1724. X{
  1725. X    /** Read the new mail for the specified person. **/
  1726. X
  1727. X    
  1728. X    FILE *mailfile;
  1729. X    char from_whom[SLEN], subject[SLEN];
  1730. X    int  sendit;
  1731. X
  1732. X    log("New mail for %s", reply_table[person].username);
  1733. X
  1734. X        if ((mailfile = fopen(reply_table[person].mailfile,"r")) == NULL)
  1735. X           return(log("can't open mailfile for user %s", 
  1736. X            reply_table[person].username));
  1737. X
  1738. X        if (fseek(mailfile, reply_table[person].mailsize, BEGINNING) == -1)
  1739. X           return(log("couldn't seek to %ld in mail file!", 
  1740. X                   reply_table[person].mailsize));
  1741. X
  1742. X    while (get_return(mailfile, person, from_whom, subject, &sendit) != -1)
  1743. X      if (sendit)
  1744. X        reply_to_mail(person, from_whom, subject);
  1745. X
  1746. X    return;
  1747. X}
  1748. X
  1749. Xint
  1750. Xget_return(file, person, from, subject, sendit)
  1751. XFILE *file;
  1752. Xint  person, *sendit;
  1753. Xchar *from, *subject;
  1754. X{
  1755. X    /** Reads the new message and return the from and subject lines.
  1756. X        sendit is set to true iff it isn't a machine generated msg
  1757. X    **/
  1758. X    
  1759. X    char name1[SLEN], name2[SLEN], lastname[SLEN];
  1760. X    char buffer[SLEN], hold_return[NLEN];
  1761. X    int done = 0, in_header = 0;
  1762. X
  1763. X    from[0] = '\0';
  1764. X    name1[0] = '\0';
  1765. X    name2[0] = '\0';
  1766. X    lastname[0] = '\0';
  1767. X    *sendit = 1;
  1768. X
  1769. X    while (! done) {
  1770. X
  1771. X      if (fgets(buffer, SLEN, file) == NULL)
  1772. X    return(-1);
  1773. X
  1774. X      if (first_word(buffer, "From ")) {
  1775. X    in_header++;
  1776. X    sscanf(buffer, "%*s %s", hold_return);
  1777. X      }
  1778. X      else if (in_header) {
  1779. X        if (first_word(buffer, ">From")) {
  1780. X      sscanf(buffer,"%*s %s %*s %*s %*s %*s %*s %*s %*s %s", name1, name2);
  1781. X      add_site(from, name2, lastname);
  1782. X        }
  1783. X        else if (first_word(buffer,"Subject:")) {
  1784. X      remove_return(buffer);
  1785. X      strcpy(subject, (char *) (buffer + 8));
  1786. X        }
  1787. X        else if (first_word(buffer,"X-Mailer: fastmail"))
  1788. X      *sendit = 0;
  1789. X        else if (strlen(buffer) == 1)
  1790. X      done = 1;
  1791. X      }
  1792. X    }
  1793. X
  1794. X    if (from[0] == '\0')
  1795. X      strcpy(from, hold_return); /* default address! */
  1796. X    else
  1797. X      add_site(from, name1, lastname);    /* get the user name too! */
  1798. X
  1799. X    return(0);
  1800. X}
  1801. X
  1802. Xadd_site(buffer, site, lastsite)
  1803. Xchar *buffer, *site, *lastsite;
  1804. X{
  1805. X    /** add site to buffer, unless site is 'uucp', or the same as 
  1806. X        lastsite.   If not, set lastsite to site.
  1807. X    **/
  1808. X
  1809. X    char local_buffer[SLEN], *strip_parens();
  1810. X
  1811. X    if (strcmp(site, "uucp") != 0)
  1812. X      if (strcmp(site, lastsite) != 0) {
  1813. X          if (buffer[0] == '\0')
  1814. X            strcpy(buffer, strip_parens(site));         /* first in list! */
  1815. X          else {
  1816. X            sprintf(local_buffer,"%s!%s", buffer, strip_parens(site));
  1817. X            strcpy(buffer, local_buffer);
  1818. X          }
  1819. X          strcpy(lastsite, strip_parens(site)); /* don't want THIS twice! */
  1820. SHAR_EOF
  1821. echo "End of part 22"
  1822. echo "File utils/arepdaem.c is continued in part 23"
  1823. echo "23" > s2_seq_.tmp
  1824. exit 0
  1825.  
  1826.